package com.eveinfo.api.utils.nametoid;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;

public class NameToIdParser extends AbstractApiParser<ApiNameToId, NameToIdHandler> {
	private static final String PARAM = "names";
	private static final String NAMETOID_URL = "/eve/CharacterID.xml.aspx";

	private static NameToIdParser instance;

	public static NameToIdParser getInstance() {
		if (instance == null) {
			instance = new NameToIdParser();
		}
		return instance;
	}

	private NameToIdParser() {
		super(ApiNameToId.class, 1, NAMETOID_URL);
	}

	public ApiNameToId getNameToId(String name) throws IOException, SAXException,
 ParserConfigurationException,
			ApiException, NoCacheFoundExecption {
		NameToIdHandler handler = new NameToIdHandler();
		return getResponse(PARAM, name, handler);
	}

	public static boolean isInstancier() {
		return instance != null;
	}

}